Sequence diagram = represents an interaction; can only show interactions so model element type: interaction; in form:
sd [Interaction] interaction name [diagram name]
[1] What is the diagram kind for a sequence diagram, and which type of model element does it represent? A = sd / interaction only;
[2] What is the context for an executing interaction? A = between structural elements of a block with sequence of message exchanges; interactions take place in the context of a block between elements of its internal structure.
[3] Draw a sequence diagram with two lifelines: one representing a part with no name, typed by the actor “Customer, ” and the other with the name “m, ” typed by the block “Vending Machine. ” A = Figure 9.1 similar
[4] What is a selector expression used for? A = used to explicitly identify one instance when there are multiplicity greater than 1 on lifelines. Noted by [name] on the header of lifeline: ex [Elvis]
[5] Which kinds of event are relevant when specifying interactions? A=
Event = describes thing what happen on instance of lifeline, three categories of events are relevant to interactions:
– Sending and receiving of messages
– Start and completion of actions and behaviors
– Creation and destruction of instances
[6] List the different types of messages that can be exchanged between lifelines.
Messages = exchanged between lifelines to achieve interactions; two basic types are asynchronous (open arrowhead) and synchronous (closed arrowhead); open arrow head with dashed line is reply message;
[7] On the diagram from Question 3, add a message from the “Customer” lifeline to the “Vending Machine ” lifeline representing the signal “Select Product ” with the argument“C3. ” A = similar to Figure 9.4
Weak sequencing = messages should follow lifeline sequentially, if not, its weak sequencing:
[8] What does the term “message overtaking ” mean? A message response is late, because of weak sequencing, B.recieve happens after C.send so it was overtook.
[9] How is an action or behavior execution represented on a sequence diagram?
Arrival of a message at lifeline triggers execution of behavior (method) for the operation or reception that the message represents; focus of control bars or activations are overlaid on lifelines and correspond to executions, which can be stacked for nested executions, or it can just be written out in another box;
[10] What is an observation and how is it used?
Time observation – notes the time at some instant during execution; duration observation – notes the time taken between two instants during the execution of the interaction; time constraint and duration constraint can use observations to express constraints involving the values of those observations; shown as standard constraint expression with {braces};
In Figure 9.10, time observation, t, is taken when the first self-test message is sent using the expression t= now.
[11] In the diagram from Question 7, observe the current time (provided by the “ clock ” function) when the “ Select Product ” message is sent? ANS = similar to 9.10, add t=now at select product message;
[12] How is a combined fragment represented on a sequence diagram?
Combine fragments = complex pattern of interaction – specifies different rules for ordering of messages; groups these messages based on operator; consists of interactionoperator and its operands; interaction operator defines the type of ordering logic; operands has guard containing a constraint expression; interaction operators are the following ([13] Name four common interaction operators):
– Seq = weak sequencing – all other sequences so not really noted
– Par = parallel; operands can occur in parallel
– Alt/else = operator where exactly one of its operands will be selected based on guard rule; each option partitioned
– Opt = optional; unary operator that is same as alt, this operand will be executed or skipped
– Loop = operator where the trace represented by its operand repeats; bounds are documented in brackets after loop keyword
There are some other interaction operators that are not as popular:
– Strict = like seq, except ordered across all lifelines
– Break = remainder of enclosing fragment is not executed; breaks out, ends fragment
– Critical = sequence of operands must take place with no interleaving of other occurrences
– Neg = negation = traces described by its operand cannot occur
Example below has 1 – 3 in opt fragment but only 1 + 4 in loop fragment
[14] In the diagram from Question 7, change “Select Product ” from a signal to an operation on “Vending Machine ” and show two different replies: If the machine has stock, then it replies with the return string “Stock Available ”; otherwise, it replies with the string “ Sold Out. ”
[15] Messages M1 and M2 from lifeline L2 can occur in any order on lifeline L1. Show two different ways that this can be expressed on a sequence diagram.
[16] Are the lifelines that participate in a combined fragment shown in front of or behind the frame box for the combined fragment? A = in front – see example 9.11
[17] Which messages are valid inside an ignore fragment? ANS = anything not in the {braces}
Following operators provide ability to filter messages in their operand:
- Consider = only consider messages in specified set of operations / signals; use for checking valid or not;
- Ignored = do not consider messages for specified set of operations / signals; assert operator used to provide a mechanism to assert only the occurrences in its operand are valid; shown in {braces} following keyword in fragment label;
[18] What does a state invariant specify?
State invariant = add constraint on the required state of a lifeline at a given point; noted two different ways – expression in {braces} or state symbol on the lifeline. Figure 9.14 shows both variants:
[19] What are gates used for?
Interactions can be nested or reference interaction outside of the current diagram; this is done with formal gates = at boundary references another interaction; noted as the line hitting the frame boundary (figure 9.12);
Another notation is to use the ref frame within diagram.
[20] Name two ways of showing the interaction between the children of a lifeline.
Lifeline decomposition = can put some interactions into a black-box where parent just sees frame nested in it, but can be expanded to see the decomposition (same idea as referencing external interactions and noted the same way); In Figure 9.15 this was shown with “ref” on the Alarm System – ref During Alert. Below is the decomposition of During Alert:
Alternate way to reference decompositions (unlike 9.15) is to show the nested lifelines within the parent diagram; the top interaction will have multiple lifelines below it. (a white box view in 9.17)
[21] Are the lifelines that participate in an interaction occurrence shown in front of or behind the frame box for the interaction occurrence? ANS = Behind – look at Figure 9.15